﻿<%@ Page Title="" Language="C#" Inherits="System.Web.Mvc.ViewPage<Sita.Entities.Invoice>" %>

<html>
<head>
    <title></title>
</head>
<body>
    Web:<%: Model.BusinessUnit.Web %><br />
    Direccion:<%: Model.BusinessUnit.Address %><br />
    Codigo Postal:<%: Model.BusinessUnit.PostalCode %><br />
    Provincia:<%: Model.BusinessUnit.State %><br />
    Telefono:<%: Model.BusinessUnit.Phone %><br />
    Email:<%: Model.BusinessUnit.Email %><br />
    IVA:<%: Model.BusinessUnit.IVAType %><br />
    Lugar de emision:<%: Model.BusinessUnit.Name %><br />
    CUIT:<%: Model.BusinessUnit.CUIT %><br />
    Ing Brutos:<%: Model.BusinessUnit.Incomes %><br />
    Fecha inicio act:<%: Model.BusinessUnit.InitialDate %><br>
    <br>
    Nro. Factura:<%: Model.InvoiceID %><br>
    Fecha Emision:<%: Model.CreationDate %><br>
    <br>
    Para:
    <%: Model.Customer.CompanyName %><br />
    Direccion:<%: Model.Customer.Address %><br />
    Codigo Postal:<%: Model.Customer.PostalCode %><br />
    IVA:<%: Model.Customer.IVAType %><br />
    Nro:<%: Model.Customer.CustomerID %><br />
    Provincia:<%: Model.Customer.State %><br />
    CUIT:<%: Model.Customer.CUIT %><br />
    <br />
    <%decimal totalPrice = 0; %>
    LISTADO DE REMITOS:<br />
    <%if (Model.InvoiceDeliveryNotes.Count > 0)
      {
          foreach (Sita.Entities.InvoiceDeliveryNote idn in Model.InvoiceDeliveryNotes)
          {
              Sita.Entities.DeliveryNote dn = idn.DeliveryNote;
              if (dn.DeliveryNoteReplacements.Count() > 0)
              {%>
    Remito Nro.
    <%: dn.DeliveryNoteID%><br />
    <table class="table table-bordered">
        <thead>
            <tr>
                <td>
                    Codigo
                </td>
                <td>
                    Descripcion
                </td>
                <td>
                    Cantidad
                </td>
                <td>
                    Precio Unitario
                </td>
                <td>
                    Precio Total
                </td>
            </tr>
        </thead>
        <tbody>
            <%foreach (Sita.Entities.DeliveryNoteReplacement r in dn.DeliveryNoteReplacements)
              { %>
            <tr>
                <td>
                    <%: r.Replacement.Code%>
                </td>
                <td>
                    <%: r.Replacement.Name%>
                </td>
                <td>
                    <%: r.Quantity%>
                </td>
                <td>
                    <%: r.UnitPrice%>
                </td>
                <td>
                    <%: r.TotalPrice%>
                </td>
            </tr>
            <%totalPrice += r.TotalPrice;
              }%>
        </tbody>
    </table>
    <%}
          } %>
    <%} %>
    <br />
    LISTADO DE PRODUCTOS:<br />
    <%if (Model.InvoiceReplacements.Count() > 0)
      {%>
    <table class="table table-bordered">
        <thead>
            <tr>
                <td>
                    Codigo
                </td>
                <td>
                    Descripcion
                </td>
                <td>
                    Cantidad
                </td>
                <td>
                    Precio Unitario
                </td>
                <td>
                    Precio Total
                </td>
            </tr>
        </thead>
        <tbody>
            <%foreach (Sita.Entities.InvoiceReplacement ir in Model.InvoiceReplacements)
              { %>
            <tr>
                <td>
                    <%: ir.Replacement.Code%>
                </td>
                <td>
                    <%: ir.Replacement.Name%>
                </td>
                <td>
                    <%: ir.Quantity%>
                </td>
                <td>
                    <%: ir.UnitPrice%>
                </td>
                <td>
                    <%: ir.TotalPrice%>
                </td>
                <%totalPrice += ir.TotalPrice;
              }%>
        </tbody>
    </table>
    <%}%>
    <br />
    LISTADO DE EXTRAS:<br />
    <%if (Model.InvoiceExtraItems.Count() > 0)
      {%>
    <table class="table table-bordered">
        <thead>
            <tr>
                <td>
                    Codigo
                </td>
                <td>
                    Descripcion
                </td>
                <td>
                    Cantidad
                </td>
                <td>
                    Precio Unitario
                </td>
                <td>
                    Precio Total
                </td>
            </tr>
        </thead>
        <tbody>
            <%foreach (Sita.Entities.InvoiceExtraItem iei in Model.InvoiceExtraItems)
              { %>
            <tr>
                <td>
                    &nbsp;
                </td>
                <td>
                    <%: iei.Description%>
                </td>
                <td>
                    <%: iei.Quantity%>
                </td>
                <td>
                    <%: iei.UnitPrice%>
                </td>
                <td>
                    <%: iei.TotalPrice%>
                </td>
                <%totalPrice += iei.TotalPrice;
              }%>
        </tbody>
    </table>
    <%}%><br />
    <br />
    <%decimal IVAPrice = totalPrice * 0.21M;
      decimal totalPriceWithIVA = totalPrice + IVAPrice; %>
    Subtotal: <%: totalPrice %>
    IVA 21%: <%: IVAPrice%>
    Total: <%: totalPriceWithIVA%>
</body>
</html>
